package com.cn.boot.student.controller.student.team;

import com.cn.boot.student.entity.TeamUserRelationEntity;
import com.cn.boot.student.service.team.ITeamUserRelationService;
import com.cn.boot.student.util.CommonResult;
import com.cn.boot.student.vo.TeamParams;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/***
 * 小组用户关系控制器
 * @author luosir
 */
@RestController
@Api(tags ="小组用户关系管理接口")
@RequestMapping("/admin/tur")
public class TeamUserRelationController {
    @Autowired
    private ITeamUserRelationService iTeamUserRelationService;

    /**
     * 根据小组id得到小组成员
     * @return
     */
    @GetMapping("/getStudentByTeamId")
    @PreAuthorize("hasAuthority('sys:team:read')")
    @ApiOperation(value = "根据小组id得到小组成员")
    public CommonResult getStudentByTeamId(Integer id){
        return iTeamUserRelationService.getStudentByTeamId(id);
    }

//    /**
//     * 分配小组成员(单个学员分配)
//     * @param entity
//     * @return
//     */
//    @PostMapping("/assignStudent")
//    @PreAuthorize("hasAuthority('sys:team:update')")
//    @ApiOperation("分配小组成员(单个)")
//    public CommonResult assignStudent( TeamUserRelationEntity entity){
//        return iTeamUserRelationService.assignStudent(entity);
//    }
    /**
     * 分配小组成员(批量分配)
     * @param entityList
     * @return
     */
    @PostMapping("/assignStudents")
    @PreAuthorize("hasAuthority('sys:team:update')")
    @ApiOperation(value = "分配小组成员(批量)")
    public CommonResult assignStudents(@RequestBody List<TeamUserRelationEntity> entityList){
        return iTeamUserRelationService.assignStudents(entityList);
    }
//
//    /**
//     *删除小组成员(单个)
//     * @param entity
//     * @return
//     */
//    @PostMapping("/del")
//    @PreAuthorize("hasAuthority('sys:team:del')")
//    @ApiOperation("删除小组成员(单个)")
//    public CommonResult del(TeamUserRelationEntity entity){
//        return iTeamUserRelationService.del(entity);
//    }

    /**
     *删除小组成员(批量)
     * @param entityList
     * @return
     */
    @PostMapping("/dels")
    @PreAuthorize("hasAuthority('sys:team:del')")
    @ApiOperation(value = "删除小组成员(批量)")
    public CommonResult dels(@RequestBody List<TeamUserRelationEntity> entityList){
        return iTeamUserRelationService.dels(entityList);
    }
}
